{template 'common/header'}
<ul class="nav nav-tabs">
	{if $type['name'] == 'home'}<li{if $do == 'display'} class="active"{/if}><a href="{php echo url('site/nav/home', array('m' => $m));}">微站首页导航图标</a></li>{/if}
	{if $type['name'] == 'profile'}<li{if $do == 'display'} class="active"{/if}><a href="{php echo url('site/nav/profile', array('m' => $m));}">个人中心功能条目</a></li>{/if}
	{if $type['name'] == 'shortcut'}<li{if $do == 'display'} class="active"{/if}><a href="{php echo url('site/nav/shortcut', array('m' => $m));}">快捷菜单</a></li>{/if}
	{if $type['name'] == 'shortcut'}
		<li><a href="{php echo url('site/shortcut');}">快捷菜单风格</a></li>
	{/if}
	{if empty($module)}
	<li{if $do == 'post' && empty($id)} class="active"{/if}><a href="{php echo url('site/nav/' . $type['name'], array('foo' => 'post'));}"><i class="fa fa-plus"></i> 添加条目</a></li>
	{/if}
	{if $do == 'post' && !empty($id)}
	<li class="active"><a href="{php echo url('site/nav/' . $type['name'], array('id' => $id, 'foo' => 'post'));}"><i class="fa fa-edit"></i> 编辑条目</a></li>
	{/if}
</ul>
{if $do == 'post'}
<form class="form-horizontal form" action="" method="post" enctype="multipart/form-data">
<div class="main">
	<input type="hidden" name="id" value="{$id}" />
	<input type="hidden" name="foo" value="post" />
	<input type="hidden" name="do" value="{$_GPC['do']}" />
	<input type="hidden" name="templateid" value="{$template['id']}">
	<h5 class="page-header">微站导航</h5>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">微站导航位置</label>
			<div class="col-sm-10">
				{if empty($item['position']) || empty($item['module'])}
				<select class="form-control" name="position">
					{loop $types $key $p}
					<option value="{$p['position']}"{if $type['name'] == $key} selected="selected"{/if}>{$p['title']}</option>
					{/loop}
				</select>
				<span class="help-block">这个导航链接将显示在微站指定页面. 注意: 此项添加后不能修改.</span>
				{else}
				<span class="help-block">这个导航链接将显示在微站{$type['title']}页面</span>
				{/if}
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">名称</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="title" id="name" value="{$item['name']}" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">描述</label>
			<div class="col-sm-10">
				<textarea style="height:200px;" class="form-control" name="description" cols="70">{$item['description']}</textarea>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">链接</label>
			<div class="col-sm-10">
				{php echo tpl_form_field_link('url', $item['url']);}
				<span class="help-block">指定这个导航的链接目标</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
			<div class="col-sm-10">
				<label for="status_1" class="radio-inline"><input autocomplete="off" type="radio" name="status" id="status_1" value="1" {if $item['status'] == 1 || empty($item)} checked="checked"{/if} /> 显示</label>
				<label for="status_0" class="radio-inline"><input autocomplete="off" type="radio" name="status" id="status_0" value="0" {if !empty($item) && $item['status'] == 0} checked="checked"{/if} /> 隐藏</label>
				<span class="help-block">设置导航菜单的显示状态</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">排序</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="displayorder" value="{$item['displayorder']}" />
				<span class="help-block">导航排序，越大越靠前</span>
			</div>
		</div>
	<h5 class="page-header">导航样式</h5>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">系统图标</label>
			<div class="col-sm-10">
				{php echo tpl_form_field_icon('icon[icon]', $item['css']['icon']['icon']);}
				<span class="help-block">导航的背景图标，微擎系统提供丰富的图标ICON。</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">图标颜色</label>
			<div class="col-sm-10">
				{php echo tpl_form_field_color('icon[color]', $item['css']['icon']['color']);}
				<span class="help-block">图标颜色，上传图标时此设置项无效</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">图标大小</label>
			<div class="col-sm-10">
				<div class="input-group">
					<input class="form-control" type="text" name="icon[size]" id="icon" value="{if $item['css']['icon']['size']}{$item['css']['icon']['size']}{else}35{/if}">
					<span class="input-group-addon">px</span>
				</div>
				<span class="help-block">图标的尺寸大小，单位为像素，上传图标时此设置项无效</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">上传图标</label>
			<div class="col-sm-10">
				{php echo tpl_form_field_image('iconfile', $item['fileicon']);}
				<span class="help-block">自定义上传图标图片，“系统图标”优先于此项</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
			<div class="col-sm-10">
				<input name="token" type="hidden" value="{$_W['token']}" />
				<input type="submit" class="btn btn-primary" name="submit" value="提交" />
			</div>
		</div>
</div>
</form>

{elseif $do == 'display'}

<script type="text/javascript">
	require(['bootstrap.switch'], function($){
		$(function(){
			$(':checkbox').bootstrapSwitch();
			$(':checkbox').on('switchChange.bootstrapSwitch', function(e, state){
				$this = $(this);
				var dat = $this.attr('data');
				var ret = this.checked ? 1 : 0;
				$.post(location.href, {dat: dat, ret: ret}, function(resp){
					if(resp == 'success') {
						window.setTimeout(function(){location.href = location.href;}, 300);
					}
				});
			});
		});
	});
</script>

<style>
.table td input{margin-bottom:0;}
</style>
<form action="" method="post">
<div class="main">
	<div class="stat">
		{if $position == '1'}
		<h4 class="sub-title">选择要显示在微站首页的信息 <small>这里提供了{if $mod}"{$mod['title']}"功能中{/if}能够显示在微站首页的信息, 你可以选择性的自定义或显示隐藏</small></h4>
		{/if}
		{if $position == '2'}
		<h4 class="sub-title">选择要显示在微站个人中心的信息 <small>这里提供了{if $mod}"{$mod['title']}"功能中{/if}能够显示在微站个人中心的信息, 你可以选择性的自定义或显示隐藏</small></h4>
		{/if}
		{if $position == '3'}
		<h4 class="sub-title">选择要显示在微站快捷选项的信息 <small>这里提供了{if $mod}"{$mod['title']}"功能中{/if}能够显示在微站快捷选项的信息(需要微站模板支持), 你可以选择性的自定义或显示隐藏</small></h4>
		{/if}
		<table class="table table-hover table-responsive">
			<thead class="navbar-inner">
				<tr>
					<th style="width:40px;">ID</th>
					<th style="width:44px;">图标</th>
					<th style="width:120px;">标题</th>
					<th>链接</th>
					<th style="width:100px;">来源</th>
					<th style="width:60px;">排序</th>
					<th style="width:250px; text-align:right;">是否在微站上显示</th>
				</tr>
			</thead>
			<tbody>
				{loop $ds $item}
				{if empty($_GPC['name'])}
				{if $item['checked'] || !$item['module']}
				<tr>
					<td>{$item['id']}</td>
					<td><div style="width:40px; overflow:hidden;">{if !empty($item['css']['icon']['icon'])}<i class="{$item['css']['icon']['icon']} fa fa-2x"></i>{elseif !empty($item['icon'])}<img src="{$_W['attachurl']}{$item['icon']}" style="width:30px !important;" />{/if}</div></td>
					<td>{if $item['remove']}<input type="text" class="form-control" name="title[{$item['id']}]" value="{$item['title']}" />{else}{$item['title']}{/if}</td>
					<td>
						{php echo tpl_form_field_link('url['.$item['id'].']', $item['url']);}
					</td>
					<td><div style="overflow:hidden; text-overflow:ellipsis; white-space:nowrap">{if $item['module']}"{$_W['account']['modules'][$item['module']]['title']}" {/if}{$froms[$item['from']]}</div></td>
					<td>{if $item['remove']}<input type="text" class="form-control" name="displayorder[{$item['id']}]" value="{$item['displayorder']}" />{else}无效{/if}</td>
					<td style="text-align:right;">
						<div class="btn-group text-left">
							<a class="btn btn-default btn-sm" href="{php echo url('site/nav/'.$_GPC['do'], array('id' => $item['id'],'foo' =>'post'));}" {if !$item['checked']} style="display:;"{/if} title="编辑"><i class="fa fa-edit"></i>编辑</a>
							<a class="btn btn-default btn-sm" href="{php echo url('site/nav/'.$_GPC['do'], array('id' => $item['id'],'foo'=>'delete', 'name' => $modulename));}" {if !$item['remove']} style="display:;"{/if} title="删除"><i class="fa fa-times"></i> 删除</a>
						</div>
						<input type="checkbox" value="1"{if intval($item['status'])==1} checked="checked"{/if} data="{php echo base64_encode(json_encode($item));}"/>
					</td>
				</tr>
				{/if}
				{else}
				<tr>
					<td>{$item['id']}</td>
					<td>{if $item['css']['icon']['icon'] && empty($item['icon'])}<i class="{$item['css']['icon']['icon']} icon-2x"></i>{else}{if $item['icon']}<img src="{$_W['attachurl']}{$item['icon']}" width="30" />{/if}{/if}</td>
					<td>{if $item['remove']}<input type="text" class="span2" name="title[{$item['id']}]" value="{$item['title']}" />{else}{$item['title']}{/if}</td>
					<td>
						{php echo tpl_form_field_link('url['.$item['id'].']', $item['url']);}
					</td>
					<td><div style=" overflow:hidden; text-overflow:ellipsis; white-space:nowrap">{if $item['module']}"{$_W['account']['modules'][$item['module']]['title']}" {/if}{$froms[$item['from']]}</div></td>
					<td>{if $item['remove']}<input type="text" class="span1" name="displayorder[{$item['id']}]" value="{$item['displayorder']}" />{else}无效{/if}</td>
					<td style="text-align:right;">
						<div style="width:175px; float:right;">
							<a href="{php echo url('site/nav/post', array('id' => $item['id'], '_p' => $position));}" class="btn edit btn-small"{if !$item['checked']} style="display:none;"{/if} title="编辑"><i class="icon-edit"></i></a>
							<a href="{php echo url('site/nav/delete', array('id' => $item['id'], 'name' => $modulename));}" class="btn remove btn-small"{if !$item['remove']} style="display:none;"{/if} title="删除"><i class="icon-remove"></i></a>
							<div class="make-switch switch-small" data-on-label="是" data-off-label="否">
								<input type="checkbox" value="20"{if $item['checked']} checked="checked"{/if} data="{php echo base64_encode(json_encode($item));}" />
							</div>
						</div>
					</td>
				</tr>
				{/if}
				{/loop}
			</tbody>
			<tr>
				<td colspan="7">
					<input name="token" type="hidden" value="{$_W['token']}" />
					<input type="hidden" name="foo" value="saves" />
					<input type="submit" class="btn btn-primary" name="submit" value="提交" />
				</td>
			</tr>
		</table>
	</div>
</div>
</form>
{/if}
{template 'common/footer'}
